package com.shijunhao.graduation.service.system;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.lang.Nullable;

import java.util.Collection;
import java.util.List;

/**
 * @author: shijunhao
 * @date: 2022/3/2 15:14
 * @description:
 */
public interface BaseService<T> {

    /**
     * @param id: 查询的id
     * @return: T 响应实体类
     * @author: shijunhao
     * @date: 2022/3/2 16:26
     * @description:
     */
    T getById(@Nullable Long id);

    /**
     * @param ids: 查询的id列表
     * @return: List<T> 响应实体类列表
     * @author: shijunhao
     * @date: 2022/3/2 21:58
     * @description:
     */
    List<T> listByIds(Long... ids);
    List<T> listByIds(Collection<Long> ids);
    List<T> listByCondition(Wrapper<T> wrapper);

    /**
     * @param page: 分页参数
     * @param wrapper: 查询条件
     * @return: com.baomidou.mybatisplus.core.metadata.IPage<T>
     * @author: shijunhao
     * @date: 2022/3/6 23:14
     * @description:
     */
    Page<T> page(IPage<T> page, Wrapper<T> wrapper);
    Page<T> page(IPage<T> page);

    /**
     * @param wrapper: 查询条件
     * @return: List<T> 响应实体类列表
     * @author: shijunhao
     * @date: 2022/3/2 21:58
     * @description:
     */
    List<T> selectByCondition(Wrapper<T> wrapper);
    T getOne(Wrapper<T> wrapper);

    /**
     * @param entities: 实体类列表
     * @return: int 数量
     * @author: shijunhao
     * @date: 2022/3/2 21:58
     * @description:
     */
    boolean insertBatch(Collection<T> entities);
    boolean insertOne(T entity);


    /**
     * @param entity: 更新后实体
     * @return: boolean
     * @author: shijunhao
     * @date: 2022/3/4 16:46
     * @description:
     */
    boolean updateById(T entity);
    boolean updateByIds(Collection<T> entities);

    /**
     * @param id: 删除的id
     * @return: boolean
     * @author: shijunhao
     * @date: 2022/3/4 16:54
     * @description:
     */
    boolean deleteById(Long id);
    boolean deleteByIds(Collection<Long> ids);
    boolean deleteByCondition(Wrapper<T> wrapper);


    /**
     * @param wrapper:  条件查询
     * @return: int
     * @author: shijunhao
     * @date: 2022/4/17 1:39
     * @description: 查询数量
     */
    int selectCount(Wrapper<T> wrapper);
}
